package com.bjsxt.base.conn007_volatile;

import java.math.BigDecimal;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;

public class VolatileNoAtomic extends Thread {
    // 不具备原子性
    // private static volatile int count;
    // 具备原子性
    private static AtomicInteger count = new AtomicInteger(0);
    private static /*synchronized*/ void addCount() {
        for(int i=0; i < 1000; i++) {
            //count ++;
            count.incrementAndGet();// ++
        }
        System.out.println(count);
    }
    public void run() {
        addCount();
    }

    public static void main(String[] args) {
        /*VolatileNoAtomic[] arr = new VolatileNoAtomic[10];
        for(int i=0; i < 10; i++) {
            arr[i] = new VolatileNoAtomic();
        }
        for(int i=0; i < 10; i++) {
            arr[i].start();
        }*/
        /*String uuid = UUID.randomUUID().toString().replace("-", "");
        System.out.println(uuid);*/
        /*String phone = "18611701769";
        System.out.println(transfer(phone, 3, 6));
        String id = "36220219910705661X";
        System.out.println(transfer(id, 6, 13));
        String name = "吴剑好爱爱爱";
        System.out.println(transfer(name, 1, name.length()-1));*/

        BigDecimal num = new BigDecimal(2);
        int i = num.compareTo(BigDecimal.ZERO);
        System.out.println(i);

    }

    public static String transfer(String phone, int start, int end) {
        StringBuffer buffer = new StringBuffer();
        buffer.append(phone.substring(0, start));
        for(int i = 0; i < (end-start+1); i++) {
            buffer.append("*");
        }
        buffer.append(phone.substring(end+1));
        return buffer.toString();
    }

}
